
package com.idealighter.game.games.happyfive.handler;

import com.idealighter.game.core.annotation.ResMsgHandler;
import com.idealighter.game.games.happyfive.HappyFivePlayer;
import com.idealighter.game.games.happyfive.message.ReqDealCardOverMsg;
import com.idealighter.game.games.happyfive.message.ResDealCardsMsg;
import com.idealighter.game.message.core.ResMessage;
import com.idealighter.game.robot.core.Player;
import com.idealighter.game.robot.handler.ResMessageHandler;
import com.idealighter.utils.code.RandCodeUtil;

import java.util.concurrent.TimeUnit;


@ResMsgHandler(507207)
public class ResDealCardsHandler implements ResMessageHandler {

  // private static final Logger LOG = LoggerFactory.getLogger(ResDealCardsHandler.class);

  @Override
  public void action(Player player, ResMessage message) {
    ResDealCardsMsg msg = (ResDealCardsMsg) message;
    HappyFivePlayer happyFivePlayer = (HappyFivePlayer) player;
    happyFivePlayer.cardList.add(msg.getHiddenCards());
    happyFivePlayer.cardList.add(msg.getOpenCards());
    player.schedule(() -> player.sendMsg(new ReqDealCardOverMsg()), RandCodeUtil.random(3, 5),
        TimeUnit.SECONDS);
  }
}
